package com.kyh.util;

import javax.servlet.ServletContext;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpSession;

/**
 * @author xdh
 */
public class SessionUtil {

	public static final String MANAGER_LOGIN = "login"; // 管理员用户登录名

	public static final String MEMBER_LOGIN = "memberLogin"; // 学生用户登录名

	public static final String PICTURE_CODE = "pictureCode"; // 图形验证码

	public static final String TOKEN = "token"; // 唯一标识码

	public static final String ORDERNUM = "ordernum"; // 系统订单号
	
	public class ATTR_MANAGE {
		public static final String ADMINID = "adminid"; // 管理员muid
	}
	
	public static ServletContext application = null;
	
//	public static HashSet<HttpSession> sessionAll = new HashSet<HttpSession>();

	private SessionUtil() {
	}
	
//	public static int getSessionCount(){
//		int userCount = 0;
//		userCount = sessionAll.size();
//		return userCount;
//	}

	public static void addAttribute(HttpServletRequest request, String sessionAttribute, String sessionValue) {
		HttpSession session = request.getSession();
		session.setAttribute(sessionAttribute, sessionValue);
	}

	public static String getAttribute(HttpServletRequest request, String sessionAttribute) {
		HttpSession session = request.getSession();
		return (String) session.getAttribute(sessionAttribute);
	}

	public static void removeAttribute(HttpServletRequest request, String sessionAttribute) {
		HttpSession session = request.getSession();
		session.removeAttribute(sessionAttribute);
	}
}
